import request from '@/utils/request'

// 查询岗位列表
export function listPost(query) {
  return request({
    url: '/sys/post/list',
    method: 'post',
    params: query
  })
}

//  查询岗位列表(权限)
export function listPostAll(query) {
  return request({
    url: '/sys/post/listAll',
    method: 'post',
    params: query
  })
}

// 查询岗位详细
export function getPostByPostId(postId) {
  return request({
    url: '/sys/post/get/' + postId,
    method: 'get'
  })
}
// 查询岗位详细
export function getPostCode() {
  return request({
    url: '/sys/enterprise/getEnterpriseCode'
  })
}

// 新增岗位
export function addPost(data) {
  return request({
    url: '/sys/post/add',
    method: 'post',
    params: data
  })
}

// 修改岗位
export function updatePost(data) {
  return request({
    url: '/sys/post/update',
    method: 'post',
    params: data
  })
}

// 删除岗位
export function delPost(ids) {
  const data = {
    'ids': ids
  }
  return request({
    url: '/sys/post/remove',
    method: 'post',
    params: data
  })
}

// 导出岗位
// ---wt(system->sys)
export function exportPost(query) {
  return request({
    url: '/sys/post/export',
    method: 'get',
    params: query
  })
}

// 岗位名称查重校验
export function checkPostNameUnique(postId, postName) {
  const data = {
    'postId': postId,
    'postName': postName
  }
  return request({
    url: '/sys/post/checkPostNameUnique',
    method: 'post',
    params: data
  })
}

// 岗位名称查重校验
export function checkPostCodeUnique(postId, postCode) {
  const data = {
    'postId': postId,
    'postCode': postCode
  }
  return request({
    url: '/sys/post/checkPostCodeUnique',
    method: 'post',
    params: data
  })
}
// export function getMaxPostSort() {
//   return request({
//     url: '/sys/post/getMaxPostSort',
//     method: 'get'
//   })
// }
// 获取岗位的最大值
export function getMaxPostSort() {
  return request({
    url: '/sys/post/getDataCount',
    method: 'get'
  })
}
